package io.renren.modules.noc.controller;

import java.util.Arrays;
import java.util.Map;

import io.renren.common.sms.YxuntongSms;
import io.renren.common.validator.ValidatorUtils;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import io.renren.modules.noc.entity.NocBeerTicketBusinessEntity;
import io.renren.modules.noc.service.NocBeerTicketBusinessService;
import io.renren.common.utils.PageUtils;
import io.renren.common.utils.R;



/**
 * 啤酒节-门票-展商
 *
 * @author whc
 * @email hucheng_86@126.com
 * @date 2019-07-05 16:05:25
 */
@RestController
@RequestMapping("noc/nocbeerticketbusiness")
public class NocBeerTicketBusinessController {
    @Autowired
    private NocBeerTicketBusinessService nocBeerTicketBusinessService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    @RequiresPermissions("noc:nocbeerticketbusiness:list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = nocBeerTicketBusinessService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{id}")
    @RequiresPermissions("noc:nocbeerticketbusiness:info")
    public R info(@PathVariable("id") Integer id){
        NocBeerTicketBusinessEntity nocBeerTicketBusiness = nocBeerTicketBusinessService.getById(id);

        return R.ok().put("nocBeerTicketBusiness", nocBeerTicketBusiness);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    @RequiresPermissions("noc:nocbeerticketbusiness:save")
    public R save(@RequestBody NocBeerTicketBusinessEntity nocBeerTicketBusiness){
        nocBeerTicketBusinessService.save(nocBeerTicketBusiness);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    @RequiresPermissions("noc:nocbeerticketbusiness:update")
    public R update(@RequestBody NocBeerTicketBusinessEntity nocBeerTicketBusiness){
        ValidatorUtils.validateEntity(nocBeerTicketBusiness);
        nocBeerTicketBusinessService.updateById(nocBeerTicketBusiness);
        
        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    @RequiresPermissions("noc:nocbeerticketbusiness:delete")
    public R delete(@RequestBody Integer[] ids){
        nocBeerTicketBusinessService.removeByIds(Arrays.asList(ids));

        return R.ok();
    }

    public static void main(String[] args){
       /* String ps1 = "15953295779," +
                "15527272236," +
                "18816390105";*/

        String ps2 = "13027783575";

        String[] strs = ps2.split(",");
        String str = "尊敬的展商，2019年7月18日金诺机床展啤酒节晚宴门票已开始兑换，当日有效. 兑换链接 dwz.cn/H4bxvXqv 回T退";
        for(String s:strs){
            //YxuntongSms.sendMsg("20013121","jNHZ10+",s,str);
        }
    }

}
